package cn.fl.product.controller;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

import cmm.comm.facade.framework.api.ISysDictionaryApiService;
import cmm.comm.facade.framework.condition.SysCdMapDQueryCondition;
import cmm.comm.facade.framework.dto.SysDictionaryDTO;
import cmm.mid.core.framework.page.DataResultVO;
import cmm.mid.core.framework.page.KeyValueVO;
import cmm.mid.core.framework.page.ListPageVO;
import cmm.mid.core.framework.page.Pager;
import cmm.web.core.framework.controller.BaseController;
import cn.cmm.base.framework.constant.BaseConstant;
import cn.cmm.base.framework.constant.BaseExceptionConstant;
import cn.cmm.base.framework.exception.BaseException;
import cn.cmm.base.framework.utils.BaseLogUtils;
import cn.cmm.base.framework.utils.CollectionUtils;
import cn.cmm.base.framework.utils.DecimalUtils;
import cn.cmm.base.framework.utils.StringUtils;
import cn.fl.framework.base.context.CurrentThreadContext;
import cn.fl.framework.constant.DictionaryConstant;
import cn.fl.product.service.IPrdBscInfoService;
import cn.fl.product.vo.PrdBscInfoVO;
import cn.fl.product.vo.PrdCarInfoVO;
import cn.fl.product.vo.PrdImportInfoVO;
import cn.fl.system.constant.SysLogConstant;
import cn.fl.system.vo.SysCdMapDVO;
import fl.product.facade.product.condition.PrdBscInfoQueryCondition;
import fl.product.facade.product.constant.ProductConstant;
import net.sf.json.JSONArray;

/**
 * @Description: 产品基础信息表 控制层
 */
@Controller
@RequestMapping("/product/prdBscInfo")
public class PrdBscInfoController extends BaseController {

	private static final Logger logger = LoggerFactory.getLogger(PrdBscInfoController.class);

	/**
	 * PrdBscInfo 服务层BEAN
	 */
	@Autowired
	private IPrdBscInfoService prdBscInfoService;
	
	/**
	 * 本地数据字典服务
	 */
	@Autowired
	private ISysDictionaryApiService sysDictionaryApiService;
	
	/**
	 * 根据产品类型获取产品名称下拉数据
	 */
	@RequestMapping(value = "/getPrdNmData.do", method = {RequestMethod.POST })
	@ResponseBody
	public JSONArray getPrdNmData(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		String prdTypCd = request.getParameter("prdTypCd");
		
		List<SysDictionaryDTO> prdNmList = this.sysDictionaryApiService.searchChild(CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd(), 
				DictionaryConstant.CODE_PRD_TYE_CD, prdTypCd);
		if(CollectionUtils.isNotEmpty(prdNmList)){
			List<KeyValueVO> kvList = new ArrayList<KeyValueVO>();
			for (SysDictionaryDTO sysDictionaryDTO : prdNmList) {
				KeyValueVO kv = new KeyValueVO();
				kv.setKey(sysDictionaryDTO.getCode());
				kv.setValue(sysDictionaryDTO.getCodeNm());
				kvList.add(kv);
			}
			JSONArray prdNmListJSON = JSONArray.fromObject(kvList);
			return prdNmListJSON;
		}
		return null;
	}

	/**
	 * 到列表页面
	 */
	@RequestMapping(value = "/toListPage.do", method = { RequestMethod.GET})
	public ModelAndView toListPage(HttpServletRequest request, HttpServletResponse response) {
		String mfrId = request.getParameter("mfrId");
		BaseLogUtils.info(logger, "toListPage", "加载产品列表页面.",CurrentThreadContext.getCurrentUserName());
		ModelAndView view = new ModelAndView("product/prdBscInfo/prdBscInfoList");
		
		//获取下拉框选项
		//车辆品牌
		/*List<KeyValueVO> searchBrandList = this.prdBscInfoService.searchBrandList();
		view.addObject("searchBrandList", searchBrandList);*/
		//审核状态
		List<KeyValueVO> searchAudStsCdList = this.prdBscInfoService.searchAudStsCdList();
		view.addObject("searchAudStsCdList", searchAudStsCdList);
		//驱动
		List<KeyValueVO> searchDrvTypList = this.prdBscInfoService.searchDrvTypList();
		view.addObject("searchDrvTypList", searchDrvTypList);
		//马力
		List<KeyValueVO> searchHpList = this.prdBscInfoService.searchHpList();
		view.addObject("searchHpList", searchHpList);
		
		//查询数据字典获取产品导入模板  filePath fileName
		String downFilePath = "C:/Users/yaoxiurong/Documents/狮桥重构/产品导入模板/BatchImportCar.xls";
		String downFileName = "BatchImportCar.xls";
		view.addObject("downFilePath", downFilePath);
		view.addObject("downFileName", downFileName);
		
		view.addObject("mfrId", mfrId);
		return view;
	}
	/**
	 * 到列表详情页面
	 */
	@RequestMapping(value = "/toDetailListPage.do", method = { RequestMethod.GET})
	public ModelAndView toDetailListPage(HttpServletRequest request, HttpServletResponse response) {
		String mfrId = request.getParameter("mfrId");
		BaseLogUtils.info(logger, "toDetailListPage", "加载产品列表详情页面.",CurrentThreadContext.getCurrentUserName());
		ModelAndView view = new ModelAndView("product/prdBscInfo/prdBscInfoDetailList");
		
		//获取下拉框选项
		//车辆品牌
		/*List<KeyValueVO> searchBrandList = this.prdBscInfoService.searchBrandList();
		view.addObject("searchBrandList", searchBrandList);*/
		//审核状态
		List<KeyValueVO> searchAudStsCdList = this.prdBscInfoService.searchAudStsCdList();
		view.addObject("searchAudStsCdList", searchAudStsCdList);

		view.addObject("mfrId", mfrId);
		return view;
	}
	
	@RequestMapping(value = "/getPrdTyeData.do", method = { RequestMethod.GET})
	@ResponseBody
	public Object getPrdTyeJson(HttpServletRequest request, HttpServletResponse response) {
		
		BaseLogUtils.info(logger, "getPrdTyeJson", "获取产品类型树数据.",CurrentThreadContext.getCurrentUserName());
		try {
			//产品类型
			//JSONArray jsonArray =this.prdBscInfoService.searchPrdTyeList();
			JSONArray jsonArray =this.prdBscInfoService.searchPrdTyeListForSearch();
			return jsonArray;
		} catch (Exception e) {
			BaseLogUtils.error(logger, "getPrdTyeJson", "获取产品类型树数据失败.ERROR:"+e.getMessage(),CurrentThreadContext.getCurrentUserName());
		}
		return null;
	}
	/**
	 * 马力
	 */
	@RequestMapping(value = "/getHpData.do", method = { RequestMethod.GET,RequestMethod.POST})
	@ResponseBody
	public Object getHp(HttpServletRequest request, HttpServletResponse response) {
		
		BaseLogUtils.info(logger, "getPrdTyeJson", "获取马力下拉数据.",CurrentThreadContext.getCurrentUserName());
		try {
			List<KeyValueVO> hpList = this.prdBscInfoService.searchHpList();
			return JSONArray.fromObject(hpList.toArray());
		} catch (Exception e) {
			BaseLogUtils.error(logger, "getPrdTyeJson", "获取马力下拉数据失败.ERROR:"+e.getMessage(),CurrentThreadContext.getCurrentUserName());
		}
		return null;
	}
	
	@RequestMapping(value = "/getPrdTyeDataForSearch.do", method = { RequestMethod.GET})
	@ResponseBody
	public Object getPrdTyeDataForSearch(HttpServletRequest request, HttpServletResponse response) {
		
		BaseLogUtils.info(logger, "getPrdTyeDataForSearch", "获取列表页面查询下拉框产品类型树数据.",CurrentThreadContext.getCurrentUserName());
		try {
			//产品类型
			JSONArray jsonArray =this.prdBscInfoService.searchPrdTyeListForSearch();
			return jsonArray;
		} catch (Exception e) {
			BaseLogUtils.error(logger, "getPrdTyeJson", "获取列表页面查询下拉框产品类型树数据失败.ERROR:"+e.getMessage(),CurrentThreadContext.getCurrentUserName());
		}
		return null;
	}

	/**
	 * 到动态字段组件页面
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/toPrdDynamicFldPage.do", method = { RequestMethod.GET,RequestMethod.POST })
	public ModelAndView toDynamicBizPage(HttpServletRequest request, HttpServletResponse response) {
		String bizTypCd = request.getParameter("bizTypCd");
		String bizCd = request.getParameter("bizCd");
		String prdTypCd = request.getParameter("prdTypCd");
		String prdTypCdNm = request.getParameter("prdTypCdNm");
		String pTypNm = request.getParameter("pTypNm");
		
		ModelAndView view = new ModelAndView("product/prdBscInfo/prdBscInfoAddDynamicPage");
		if(StringUtils.isNotEmpty(bizTypCd) && StringUtils.isNotEmpty(bizCd)){
			//解析VAL 
			view.addObject("bizTypCd", bizTypCd);
			view.addObject("bizCd", bizCd);
			
			view.addObject("prdTypCd", prdTypCd);
			view.addObject("prdTypCdNm", prdTypCdNm);
			view.addObject("pTypNm", pTypNm);
			
		}else{
			view.addObject("bizTypCd", "");
			view.addObject("bizCd", "");
		}
		return view;
	}
	@RequestMapping(value = "/toCarDynamicFldPage.do", method = { RequestMethod.GET,RequestMethod.POST })
	public ModelAndView toDynamicCarPage(HttpServletRequest request, HttpServletResponse response) {
		String bizTypCd = request.getParameter("bizTypCd");
		String bizCd = request.getParameter("bizCd");
		String prdTypCd = request.getParameter("prdTypCd");
		String prdTypCdNm = request.getParameter("prdTypCdNm");
		String pTypNm = request.getParameter("pTypNm");
		
		ModelAndView view = new ModelAndView("product/prdBscInfo/prdCarInfoAddDynamicPage");
		if(StringUtils.isNotEmpty(bizTypCd) && StringUtils.isNotEmpty(bizCd)){
			//解析VAL 
			view.addObject("bizTypCd", bizTypCd);
			view.addObject("bizCd", bizCd);
			
			view.addObject("prdTypCd", prdTypCd);
			view.addObject("prdTypCdNm", prdTypCdNm);
			view.addObject("pTypNm", pTypNm);
			
		}else{
			view.addObject("bizTypCd", "");
			view.addObject("bizCd", "");
		}
		return view;
	}
	@RequestMapping(value = "/toPrdDynamicFldDetailPage.do", method = { RequestMethod.GET,RequestMethod.POST })
	public ModelAndView toDynamicBizDetailPage(HttpServletRequest request, HttpServletResponse response) {
		String bizTypCd = request.getParameter("bizTypCd");
		String bizCd = request.getParameter("bizCd");
		String prdTypCdNm = request.getParameter("prdTypCdNm");
		String pTypNm = request.getParameter("pTypNm");
		
		ModelAndView view = new ModelAndView("product/prdBscInfo/prdBscInfoDetailDynamicPage");
		if(StringUtils.isNotEmpty(bizTypCd) && StringUtils.isNotEmpty(bizCd)){
			//解析VAL 
			view.addObject("bizTypCd", bizTypCd);
			view.addObject("bizCd", bizCd);
			
			view.addObject("prdTypCd", bizCd);
			view.addObject("prdTypCdNm", prdTypCdNm);
			view.addObject("pTypNm", pTypNm);
			
		}else{
			view.addObject("bizTypCd", "");
			view.addObject("bizCd", "");
		}
		return view;
	}
	/**
	 * 获取下拉框动态数据
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/searchSysCdMapDWithTargetAtomForSelect.do", method = { RequestMethod.GET, RequestMethod.POST })
	@ResponseBody
	public Object searchSysCdMapDWithTargetAtomForSelect(HttpServletRequest request, HttpServletResponse response) throws Exception {
		String mTypCd = request.getParameter("mTypCd");
		String sGrpCd = request.getParameter("sGrpCd");
		String sCode = request.getParameter("sCode");
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_OPERATE_SUCC);
		if(StringUtils.isEmpty(mTypCd) || StringUtils.isEmpty(sGrpCd) || StringUtils.isEmpty(sCode)){
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_PARAM_IS_BAD);
			return result;
		}
		SysCdMapDQueryCondition condition = new SysCdMapDQueryCondition();
		try {//1、系统代码 2、组织架构代码 3、映射类型代码(代码映射表中) 4、原代码组值(代码映射表中) 5、原代码值(代码映射表中) 
			condition.setSysCd(CurrentThreadContext.getCurrentSysCd());
			condition.setOrgCd(CurrentThreadContext.getCurrentOrgCd());
			condition.setmTypCd(mTypCd);
			/*condition.setsGrpCd(sGrpCd);*/
			List<String> getsCodeList = new ArrayList<>();
			getsCodeList.add(sCode);
			condition.setsCodeList(getsCodeList);
			
			List<SysCdMapDVO> list = this.prdBscInfoService.searchSysCdMapDList(condition);
			JSONArray array = new JSONArray();
			if(CollectionUtils.isNotEmpty(list)){
				net.sf.json.JSONObject obj = null;
				for (SysCdMapDVO sysCdMapDVO : list) {
					obj = new net.sf.json.JSONObject();
					obj.put("sGrpCd", sysCdMapDVO.getSGrpCd());
					obj.put("sCode", sysCdMapDVO.getSCode());
					obj.put("tCode", sysCdMapDVO.getTCode());
					obj.put("tCodeNm", sysCdMapDVO.getTCodeNm());
					array.add(obj);
				}
			}
			result.setSuccess(BaseConstant.IS_YESNO_YES);
			result.setInfo(SysLogConstant.LOG_CMM_ADD_SUCC);
			result.setData(array);
			BaseLogUtils.info(logger, "searchSysCdMapDWithTargetAtomForSelect", "查询数据,DATA:" + JSONObject.toJSONString(condition), CurrentThreadContext.getCurrentUserName());
		} catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.info(logger, "searchSysCdMapDWithTargetAtomForSelect", "查询数据,DATA:" + JSONObject.toJSONString(condition) + ", ERROR:"+ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
			BaseLogUtils.error(logger, "searchSysCdMapDWithTargetAtomForSelect", "查询数据,DATA:" + JSONObject.toJSONString(condition) + ", ERROR:"+ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}

		return result;
	}
	/**
	 * 获取品牌下拉框动态数据  需要做成键入式检索,需要返回特定的JSON 所以单独获得动态数据
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/searchBrCdJSON.do", method = { RequestMethod.GET, RequestMethod.POST })
	@ResponseBody
	public Object searchBrCdJSON(HttpServletRequest request, HttpServletResponse response) throws Exception {
		String mTypCd = request.getParameter("mTypCd");
		String sGrpCd = request.getParameter("sGrpCd");
		String sCode = request.getParameter("sCode");
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_OPERATE_SUCC);
		if(StringUtils.isEmpty(mTypCd) || StringUtils.isEmpty(sGrpCd) || StringUtils.isEmpty(sCode)){
			BaseLogUtils.info(logger, "searchBrCdJSON", "===获取产品品牌数据参数不完整===mTypCd:"+mTypCd+",sGrpCd:"+sGrpCd+",sCode:"+sCode);
			return JSONArray.fromObject(new ArrayList<KeyValueVO>());
		}
		SysCdMapDQueryCondition condition = new SysCdMapDQueryCondition();
		try {
			//1、系统代码 2、组织架构代码 3、映射类型代码(代码映射表中) 4、原代码组值(代码映射表中) 5、原代码值(代码映射表中) 
			condition.setSysCd(CurrentThreadContext.getCurrentSysCd());
			condition.setOrgCd(CurrentThreadContext.getCurrentOrgCd());
			condition.setmTypCd(mTypCd);
			/*condition.setsGrpCd(sGrpCd);*/
			List<String> getsCodeList = new ArrayList<>();
			getsCodeList.add(sCode);
			condition.setsCodeList(getsCodeList);
			List<SysCdMapDVO> list = this.prdBscInfoService.searchSysCdMapDList(condition);
			List<KeyValueVO> brCdKVList = new ArrayList<KeyValueVO>();
			if(CollectionUtils.isNotEmpty(list)){
				for (SysCdMapDVO sysCdMapDVO : list) {
					KeyValueVO kv = new KeyValueVO();
					kv.setKey(sysCdMapDVO.getTCode());
					kv.setValue(sysCdMapDVO.getTCodeNm());
					brCdKVList.add(kv);
				}
			}
			JSONArray brCdJSON = JSONArray.fromObject(brCdKVList);
			BaseLogUtils.info(logger, "searchBrCdJSON", "查询数据,DATA:" + JSONObject.toJSONString(condition), CurrentThreadContext.getCurrentUserName());
			return brCdJSON;
		} catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.info(logger, "searchBrCdJSON", "查询数据,DATA:" + JSONObject.toJSONString(condition) + ", ERROR:"+ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
			BaseLogUtils.error(logger, "searchBrCdJSON", "查询数据,DATA:" + JSONObject.toJSONString(condition) + ", ERROR:"+ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}
		
		return result;
	}
	/**
	 * 列表页面查询条件品牌下拉框数据
	 * 根据当前登录人所能看到的产品类型-->产品品牌数据
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/getCurrentBrCdJSON.do", method = { RequestMethod.GET, RequestMethod.POST })
	@ResponseBody
	public Object getCurrentBrCdJSON(HttpServletRequest request, HttpServletResponse response) throws Exception {
		List<SysDictionaryDTO> searchGroupList = this.sysDictionaryApiService.searchGroup(CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd(), DictionaryConstant.CODE_PRD_TYP_CATEGORY);
		List<String> sCodeList = new ArrayList<String>();
		if(CollectionUtils.isNotEmpty(searchGroupList)){
			for (SysDictionaryDTO sysDictionaryDTO : searchGroupList) {
				String code = sysDictionaryDTO.getCode();
				if(!sCodeList.contains(code)){
					sCodeList.add(code);
				}
			}
		}
		String mTypCd = ProductConstant.SYS_MAP_M_TYP_CD_BR_CD;
		//String sGrpCd = DictionaryConstant.CODE_PRD_TYP_CATEGORY;
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_OPERATE_SUCC);
		SysCdMapDQueryCondition condition = new SysCdMapDQueryCondition();
		try {
			List<KeyValueVO> brCdKVList = new ArrayList<KeyValueVO>();
			if(CollectionUtils.isNotEmpty(sCodeList)){
				//1、系统代码 2、组织架构代码 3、映射类型代码(代码映射表中) 4、原代码组值(代码映射表中) 5、原代码值(代码映射表中) 
				condition.setSysCd(CurrentThreadContext.getCurrentSysCd());
				condition.setOrgCd(CurrentThreadContext.getCurrentOrgCd());
				condition.setmTypCd(mTypCd);
				/*condition.setsGrpCd(sGrpCd);*/
				condition.setsCodeList(sCodeList);
				List<SysCdMapDVO> list = this.prdBscInfoService.searchSysCdMapDList(condition);
				if(CollectionUtils.isNotEmpty(list)){
					for (SysCdMapDVO sysCdMapDVO : list) {
						KeyValueVO kv = new KeyValueVO();
						kv.setKey(sysCdMapDVO.getTCode());
						kv.setValue(sysCdMapDVO.getTCodeNm());
						brCdKVList.add(kv);
					}
				}
			}
			JSONArray brCdJSON = JSONArray.fromObject(brCdKVList);
			BaseLogUtils.info(logger, "getCurrentBrCdJSON", "查询数据,DATA:" + JSONObject.toJSONString(condition), CurrentThreadContext.getCurrentUserName());
			return brCdJSON;
		} catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.info(logger, "getCurrentBrCdJSON", "查询数据,DATA:" + JSONObject.toJSONString(condition) + ", ERROR:"+ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
			BaseLogUtils.error(logger, "getCurrentBrCdJSON", "查询数据,DATA:" + JSONObject.toJSONString(condition) + ", ERROR:"+ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}
		
		return result;
	}
	
	/**
	 * 到新增/修改页面
	 */
	@RequestMapping(value = "/toAddPage.do", method = { RequestMethod.GET, RequestMethod.POST })
	public ModelAndView toAddPage(HttpServletRequest request, HttpServletResponse response) {
		String id = request.getParameter("id");
		String isLink = request.getParameter("isLink");//是否是从主产品列表操作列点产品详细:如果是,屏蔽主信息修改操作,不可修改
		//String mfrId = request.getParameter("mfrId");
		BaseLogUtils.info(logger, "toAddPage", "加载产品添加页面.",CurrentThreadContext.getCurrentUserName());
		ModelAndView view = new ModelAndView("product/prdBscInfo/prdBscInfoAdd");
		
		//品牌下拉框数据
		/*List<KeyValueVO> searchBrandList = this.prdBscInfoService.searchBrandList();
		view.addObject("searchBrandList", searchBrandList);*/
		
		//厂商下拉框数据
		List<KeyValueVO> searchMfrKVList = this.prdBscInfoService.searchMfrKVList();
		view.addObject("searchMfrKVList", searchMfrKVList);
		
		view.addObject("id", id);
		view.addObject("isLink", isLink);
		//view.addObject("mfrId", mfrId);		
		
		if(StringUtils.isNotEmpty(id)){
			PrdBscInfoVO prdBscInfoVO = this.prdBscInfoService.selectById(Long.valueOf(id));
			Long mfrId = prdBscInfoVO.getMfrId();
			String mfrNm = prdBscInfoVO.getMfrNm();
			view.addObject("mfrId", mfrId);
			view.addObject("mfrNm", mfrNm);
		}
		
		String isShowAuditBtn = request.getParameter("isShowAuditBtn");//是否审核操作
		view.addObject("isShowAuditBtn", isShowAuditBtn);
		return view;
	}
	/**
	 * 到修改审核状态页面
	 */
	@RequestMapping(value = "/toModifyAudStsCdPage.do", method = { RequestMethod.GET, RequestMethod.POST })
	public ModelAndView toModifyAudStsCdPage(HttpServletRequest request, HttpServletResponse response) {
		String id = request.getParameter("id");
		BaseLogUtils.info(logger, "toModifyAudStsCdPage", "加载修改审核状态页面.",CurrentThreadContext.getCurrentUserName());
		ModelAndView view = new ModelAndView("product/prdBscInfo/prdModifyAudStsCd");
		//审核状态
		List<KeyValueVO> searchAudStsCdList = this.prdBscInfoService.searchAudStsCdList1();
		view.addObject("searchAudStsCdList", searchAudStsCdList);
		view.addObject("id", id);
		return view;
	}
	/**
	 * 到详情页面
	 */
	@RequestMapping(value = "/toDetailPage.do", method = { RequestMethod.GET, RequestMethod.POST })
	public ModelAndView toDetailPage(HttpServletRequest request, HttpServletResponse response) {
		String id = request.getParameter("id");
		BaseLogUtils.info(logger, "toDetailPage", "加载产品详情页面.",CurrentThreadContext.getCurrentUserName());
		ModelAndView view = new ModelAndView("product/prdBscInfo/prdBscInfoDetail");
		view.addObject("id", id);
		return view;
	}

	/**
	 * 初始化列表
	 */
	@SuppressWarnings("unchecked")
	@RequestMapping(value = "/initList.do", method = { RequestMethod.GET})
	@ResponseBody
	public Object initPrdList(HttpServletRequest request, HttpServletResponse response) {
		String currentPage = request.getParameter("page");
		String pageSize = request.getParameter("pagesize");
		
		String id = request.getParameter("prdId");
		String prdNm = request.getParameter("prdNm");
		
		String mfrId = request.getParameter("mfrId");
		
		String brCd = request.getParameter("brCd");
		String prdMdl = request.getParameter("prdMdl");
		String mfrNm = request.getParameter("mfrNm");
		String audStsCd = request.getParameter("audStsCd");
		String prdTypCd = request.getParameter("prdTypCd");
		String drvTyp = request.getParameter("drvTyp");
		String hp = request.getParameter("hp");
		String isHaveNeedCheckChildPrd = request.getParameter("isHaveNeedCheckChildPrd");
		
		String prdMdlsString = request.getParameter("prdMdlsString");//报价方案属性配置中配置的产品型号prdMdls
		String flag = request.getParameter("flag");//被引用为下拉框数据标识 (方案配置属性)
		String condition = request.getParameter("condition");
		String value = "";
		if(StringUtils.isNotBlank(condition)){
			String con = condition.substring(1, condition.length()-1);
			if(StringUtils.isNotBlank(con)){
				net.sf.json.JSONObject fromObject = net.sf.json.JSONObject.fromObject(con);
				value = (String) fromObject.get("value");
			}
		}
		
		Pager page = new Pager();
		if (StringUtils.isNotEmpty(currentPage)) {
			page.setCurrentPage(Integer.parseInt(currentPage));
		}

		if (StringUtils.isNotEmpty(currentPage)) {
			page.setEveryPage(Integer.parseInt(pageSize));
		}

		PrdBscInfoQueryCondition qc = new PrdBscInfoQueryCondition();
		if(StringUtils.isNotEmpty(id)){
			List<Long> ids = new ArrayList<Long>();
			ids.add(Long.valueOf(id));
			qc.setIds(ids);
		}
		if(StringUtils.isNotEmpty(prdNm)){
			qc.setPrdNm(prdNm);
		}
		if (StringUtils.isNotBlank(mfrId)) {
			qc.setMfrId(Long.valueOf(mfrId));
		}
		if (StringUtils.isNotBlank(brCd)) {
			qc.setBrCd(brCd);
		}
		if (StringUtils.isNotBlank(prdMdl)) {
			qc.setPrdMdl(prdMdl);
		}
		if (StringUtils.isNotBlank(mfrNm)) {
			qc.setMfrNm(mfrNm);
		}
		if (StringUtils.isNotBlank(audStsCd)) {
			qc.setAudStsCd(audStsCd);
		}
		if (StringUtils.isNotBlank(prdTypCd)) {
			qc.setPrdTypCd(prdTypCd);
		}
		if (StringUtils.isNotBlank(drvTyp)) {
			qc.setDrvTyp(drvTyp);
		}
		if (StringUtils.isNotBlank(hp)) {
			qc.setHp(Long.valueOf(hp));
		}
		if(StringUtils.isNotEmpty(isHaveNeedCheckChildPrd)){
			qc.setIsHaveNeedCheckChildPrd(Integer.valueOf(isHaveNeedCheckChildPrd));
		}
		
		if (StringUtils.isNotEmpty(flag)) {
			if(StringUtils.isEmpty(value)&&StringUtils.isEmpty(prdMdlsString)){//被引用为下拉框却没有查询条件返回null
				return null;
			}
			page.setEveryPage(Integer.MAX_VALUE);//最大数据量
			//qc.setAudStsCd(BaseConstant.FLOW_CHECK_STATE_PASS);//审核通过
		}
		if (StringUtils.isNotEmpty(value)) {
			qc.setPrdMdl(value.trim());
		}else if(StringUtils.isNotEmpty(prdMdlsString)){
			String[] strings = prdMdlsString.trim().split(";");
			List<String> prdMdls = new ArrayList<String>();
			for (String string : strings) {
				prdMdls.add(string);
			}
			qc.setPrdMdlList(prdMdls);
		}
		
		page.setCondition(qc);

		BaseLogUtils.info(logger, "initPrdList", "初始化产品列表数据.DATA:"+JSONObject.toJSONString(page),CurrentThreadContext.getCurrentUserName());
		
		Pager pager = this.prdBscInfoService.searchListPage(page);
		List<PrdBscInfoVO> list = (List<PrdBscInfoVO>) pager.getResultList();
		if (StringUtils.isNotEmpty(flag)) {
			int totalCount = pager.getTotalCount();
			for (PrdBscInfoVO prdBscInfoVO : list) {
				if(StringUtils.isEmpty(prdBscInfoVO.getPrdMdl())){
					list.remove(prdBscInfoVO);
					totalCount--;
				}
			}
			pager.setTotalCount(totalCount);
		}
		ListPageVO<PrdBscInfoVO> listPage = new ListPageVO<PrdBscInfoVO>(list, pager.getTotalCount());
		return listPage;
	}

	/**
	 * 修改审核状态
	 */
	@RequestMapping(value = "/modifyAudStsCd.do", method = {RequestMethod.POST })
	@ResponseBody
	public DataResultVO modifyAudStsCd(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		String audStsCd = request.getParameter("audStsCd");
		String id = request.getParameter("id");
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_OPERATE_SUCC);
		if(StringUtils.isEmpty(id) || StringUtils.isEmpty(audStsCd)){
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
			BaseLogUtils.info(logger, "modifyAudStsCd", "修改审核状态,参数不完整！", CurrentThreadContext.getCurrentUserName());
			return result;
		}
		try {
			boolean success = this.prdBscInfoService.modifyAudStsCd(Long.valueOf(id), audStsCd, new Date(), CurrentThreadContext.getCurrentUserId());
			if(!success){
				result.setSuccess(BaseConstant.IS_YESNO_NO);
				result.setInfo(SysLogConstant.LOG_CMM_DELETE_FAIL);
			}
			BaseLogUtils.info(logger, "modifyAudStsCd", "修改审核状态,ID:"+id+".audStsCd:"+audStsCd, CurrentThreadContext.getCurrentUserName());
		}catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.info(logger, "modifyAudStsCd", "修改审核状态失败,ID:"+id+".audStsCd:"+audStsCd+".ERROR:"+ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
			BaseLogUtils.error(logger, "modifyAudStsCd", "修改审核状态失败,系统错误.ID:"+id+".audStsCd:"+audStsCd+".ERROR:"+ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}

		return result;
	}
	/**
	 * 删除数据
	 */
	@RequestMapping(value = "/removeByIds.do", method = {RequestMethod.POST })
	@ResponseBody
	public DataResultVO removePrdById(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		String ids = request.getParameter("ids");
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_DELETE_SUCC);
		if(StringUtils.isEmpty(ids)){
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
			BaseLogUtils.info(logger, "removePrdById", "删除产品数据,主键参数为空！", CurrentThreadContext.getCurrentUserName());
			return result;
		}
		
		List<Long> idsList = new ArrayList<Long>();
		JSONArray idsArray = JSONArray.fromObject(ids);
		for (Object object : idsArray) {
			idsList.add(Long.valueOf(object.toString()));
		}
		try {
			boolean success = this.prdBscInfoService.removeByIds(idsList);
			if(!success){
				result.setSuccess(BaseConstant.IS_YESNO_NO);
				result.setInfo(SysLogConstant.LOG_CMM_DELETE_FAIL);
				BaseLogUtils.info(logger, "removePrdById", "删除产品数据失败,ID:"+idsList.toString(), CurrentThreadContext.getCurrentUserName());
			}
			BaseLogUtils.info(logger, "removePrdById", "删除产品数据成功,ID:"+idsList.toString(), CurrentThreadContext.getCurrentUserName());
		}catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.info(logger, "removePrdById", "删除产品数据失败,ID:"+idsList.toString()+".ERROR:"+ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
			BaseLogUtils.error(logger, "removePrdById", "删除产品数据失败,系统错误.ID:"+idsList.toString()+".ERROR:"+ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}
		
		return result;
	}

	/**
	 * 得到一条记录
	 * 
	 * @param request
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/getById.do", method = { RequestMethod.GET})
	@ResponseBody
	public Object getPrdById(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		String id = request.getParameter("id");
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_OPERATE_SUCC);
		if(StringUtils.isEmpty(id)){
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
			BaseLogUtils.info(logger, "getPrdById", "获取产品数据,主键参数为空.", CurrentThreadContext.getCurrentUserName());
			return result;
		}
		
		try {
			PrdBscInfoVO vo = this.prdBscInfoService.selectById(Long.valueOf(id));
			if(null == vo){
				result.setSuccess(BaseConstant.IS_YESNO_NO);
				result.setInfo(SysLogConstant.LOG_CMM_QUERY_DATA_IS_EMPTY);
				BaseLogUtils.info(logger, "getPrdById", "获取产品数据不存在,ID:"+id, CurrentThreadContext.getCurrentUserName());
			}
			result.setData(vo);
			BaseLogUtils.info(logger, "getPrdById", "获取产品数据成功,ID:"+id, CurrentThreadContext.getCurrentUserName());
		}catch(BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.info(logger, "getPrdById", "获取产品数据失败,ID:"+id+".ERROR:" + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}catch(Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
			BaseLogUtils.error(logger, "getPrdById", "获取产品数据失败,系统错误.ID:"+id+".ERROR:" + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}
		return result;
	}

	/**
	 * 新增
	 */
	@RequestMapping(value = "/add.do", method = { RequestMethod.POST })
	@ResponseBody
	public Object addPrd(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_ADD_SUCC);
		PrdBscInfoVO entity = new PrdBscInfoVO();
		try {
			entity = this.getRequestParamForPrdAdd(request);
			Long id = this.prdBscInfoService.add(entity);
			result.setData(id);
			BaseLogUtils.info(logger, "addPrd", "新增产品数据成功,ID:"+id+".DATA:"+JSONObject.toJSONString(entity), CurrentThreadContext.getCurrentUserName());
		}catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.info(logger, "addPrd", "新增产品数据失败.DATA:"+JSONObject.toJSONString(entity)+".ERROR:" + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
			BaseLogUtils.error(logger, "addPrd", "新增产品数据失败,系统错误.DATA:"+JSONObject.toJSONString(entity)+".ERROR:" + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}

		return result;
	}
	
	/**
	 * 批量新增
	 */
	@RequestMapping(value = "/addBatch.do", method = { RequestMethod.POST })
	@ResponseBody
	public Object addBatch(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_ADD_SUCC);
		String string = request.getParameter("value");
		string = string.replace("[", "");
		string = string.replace("]", "");
		JSONObject json = JSONObject.parseObject(string);
		String filePath = json.getString("filePath");
		
		try {
			PrdImportInfoVO batchAddPrd = this.prdBscInfoService.batchAddPrd(filePath);
			result.setData(batchAddPrd);
		}catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.info(logger, "addBatch", "批量新增产品数据失败.ERROR:" + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
			BaseLogUtils.error(logger, "addBatch", "批量新增产品数据失败,系统错误.ERROR:" + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}
		
		return result;
	}

	/**
	 * 修改
	 */
	@RequestMapping(value = "/modify.do", method = { RequestMethod.POST })
	@ResponseBody
	public Object modifyPrd(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		String id = request.getParameter("id");
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES,SysLogConstant.LOG_CMM_UPDATE_SUCC);
		PrdBscInfoVO entity = new PrdBscInfoVO();
		if(StringUtils.isEmpty(id)){
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
			BaseLogUtils.info(logger, "modifyPrd", "修改产品信息,主键参数为空！.ID:"+id, CurrentThreadContext.getCurrentUserName());
			return result;
		}
		try {
			entity = this.getRequestParamForPrdModify(request);
			entity.setId(Long.valueOf(id));
			boolean success = this.prdBscInfoService.modify(entity);
			if(!success){
				result.setSuccess(BaseConstant.IS_YESNO_NO);
				result.setInfo(SysLogConstant.LOG_CMM_UPDATE_FAIL);
				BaseLogUtils.info(logger, "modifyPrd", "修改产品数据失败.DATA:"+JSONObject.toJSONString(entity), CurrentThreadContext.getCurrentUserName());
			}
			BaseLogUtils.info(logger, "modifyPrd", "修改产品数据成功.DATA:"+JSONObject.toJSONString(entity), CurrentThreadContext.getCurrentUserName());
		}catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.info(logger, "modifyPrd", "修改产品数据失败.DATA:"+JSONObject.toJSONString(entity)+".ERROR:"+ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
			BaseLogUtils.error(logger, "modifyPrd", "修改产品数据失败,系统错误.DATA:"+JSONObject.toJSONString(entity)+".ERROR:"+ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}
		return result;
	}
	
	/**
	 * 启用产品
	 */
	@RequestMapping(value = "/enable.do", method = { RequestMethod.POST })
	@ResponseBody
	public Object enablePrd(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		String id = request.getParameter("id");
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES,SysLogConstant.LOG_CMM_ENABLE_SUCC);
		if(StringUtils.isEmpty(id)){
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
			BaseLogUtils.info(logger, "enablePrd", "启用产品,主键参数为空.", CurrentThreadContext.getCurrentUserName());
			return result;
		}

		try {
			
			boolean success = this.prdBscInfoService.enAblePrdBscInfo(Long.valueOf(id));
			if(!success){
				result.setSuccess(BaseConstant.IS_YESNO_NO);
				result.setInfo(SysLogConstant.LOG_CMM_ENABLE_FAIL);
				BaseLogUtils.info(logger, "enablePrd", "启用产品失败,ID:"+id, CurrentThreadContext.getCurrentUserName());
			}
			BaseLogUtils.info(logger, "enablePrd", "启用产品成功,ID:"+id, CurrentThreadContext.getCurrentUserName());
		}catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.info(logger, "enablePrd", "启用产品失败,ID:"+id+".ERROR:"+ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
			BaseLogUtils.error(logger, "enablePrd", "启用产品失败,系统错误.ID:"+id+".ERROR:"+ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}
		return result;
	}
	/**
	 * 禁用产品
	 */
	@RequestMapping(value = "/disable.do", method = { RequestMethod.POST })
	@ResponseBody
	public Object disablePrd(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		
		String id = request.getParameter("id");
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES,SysLogConstant.LOG_CMM_DISABLE_SUCC);
		if(StringUtils.isEmpty(id)){
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
			BaseLogUtils.info(logger, "disablePrd", "禁用产品,主键参数为空.", CurrentThreadContext.getCurrentUserName());
			return result;
		}
		
		try {
			
			boolean success = this.prdBscInfoService.disAblePrdBscInfo(Long.valueOf(id));
			if(!success){
				result.setSuccess(BaseConstant.IS_YESNO_NO);
				result.setInfo(SysLogConstant.LOG_CMM_DISABLE_FAIL);
				BaseLogUtils.info(logger, "disablePrd", "禁用产品失败,ID:"+id, CurrentThreadContext.getCurrentUserName());
			}
			BaseLogUtils.info(logger, "disablePrd", "禁用产品成功,ID:"+id, CurrentThreadContext.getCurrentUserName());
		}catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.info(logger, "disablePrd", "禁用产品失败,ID:"+id+".ERROR:"+ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
			BaseLogUtils.error(logger, "disablePrd", "禁用产品失败,系统错误.ID:"+id+".ERROR"+ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}
		return result;
	}	
	
	
	//********************私有方法********************//
	/**
	 * 获取产品参数信息
	 * @param request
	 * @return
	 * @throws BaseException
	 */
	private PrdBscInfoVO getRequestParamForPrd(HttpServletRequest request)throws BaseException{
		//基本
		String prdTypCd = request.getParameter("prdTypCd");//产品类型
		String mfrId = request.getParameter("mfrId");//厂商ID
		String mfrNm = request.getParameter("mfrNm");//厂商名称
		String brCd = request.getParameter("brCd");//品牌代码
		String prdNm = request.getParameter("prdNm");//产品名称
		String prdMdl = request.getParameter("prdMdl");//产品型号
		//String mktPc = request.getParameter("mktPc");//指导价格(市场价格)
		String guidePcDouble = request.getParameter("guidePcDouble");//建议价格
		String prdRem = request.getParameter("prdRem");//备注
		String prdCd = request.getParameter("prdCd");//产品代码
		String isValid = request.getParameter("isValid");//是否启用
		String prdClsCd = request.getParameter("prdClsCd");//产品种类
		
		//乘用车
		//String prdSeries = request.getParameter("prdSeries");//车辆编码
		String prdYr = request.getParameter("prdYr");//生产年份
		String prdCyCd = request.getParameter("prdCyCd");//国别代码
		String outVol = request.getParameter("outVol");//排量(L)
		String grboxTypCd = request.getParameter("grboxTypCd");//变速箱类型代码
		String grboxCfg = request.getParameter("grboxCfg");//变速箱配置
		String seatQtyCd = request.getParameter("seatQtyCd");//座位
		String engMdl_car = request.getParameter("engMdl_car");//发动机型号
		String engMdl = request.getParameter("engMdl");//发动机型号
		String drvTypCd = request.getParameter("drvTypCd");//驱动形式
		String carStrcCd = request.getParameter("carStrcCd");//车身结构
		String carStrcCfg = request.getParameter("carStrcCfg");//车身结构配置
		String powerTypCd = request.getParameter("powerTypCd");//动力方式
		String carCl = request.getParameter("carCl");//车身颜色
		String carLen = request.getParameter("carLen");//车身长度(m)
		String maxSpd = request.getParameter("maxSpd");//最高车速
		String prdWayCd = request.getParameter("prdWayCd");//生产方式
		String carMdl = request.getParameter("carMdl");//车型
		String othCfg = request.getParameter("othCfg");//其他配置
		String emiStdCd = request.getParameter("emiStdCd");//排放标准
		
		//新能源客车
		String batDeg = request.getParameter("batDeg");//电池度数（Kwh）
		String extMil = request.getParameter("extMil");//续航里程（KM）
		String carVol = request.getParameter("carVol");//载货空间（㎡）
		
		//专车客车
		String prdLvlCd = request.getParameter("prdLvlCd");//客车规模(产品级别)
		
		if(StringUtils.isNotEmpty(prdYr) && prdYr.length()>4){
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, "请填写格式为1999的年份日期.");
		}
		
		PrdBscInfoVO prdBscInfoVO = new PrdBscInfoVO();		//基本信息
		prdBscInfoVO.setPrdTypCd(prdTypCd);
		if(StringUtils.isNotEmpty(mfrId)){
			prdBscInfoVO.setMfrId(Long.valueOf(mfrId));
		}
		prdBscInfoVO.setMfrNm(mfrNm);
		prdBscInfoVO.setBrCd(brCd);
		if(StringUtils.isNotEmpty(prdNm)){
			prdBscInfoVO.setPrdNm(prdNm.trim());
		}
		if(StringUtils.isNotEmpty(prdMdl)){
			prdBscInfoVO.setPrdMdl(prdMdl.trim());
		}
		if(StringUtils.isNotEmpty(guidePcDouble)){
			prdBscInfoVO.setGuidePc(DecimalUtils.convertYuanToFen(Double.valueOf(guidePcDouble)));//元to分
		}
		prdBscInfoVO.setPrdRem(prdRem);
		prdBscInfoVO.setPrdCd(prdCd);
		if(StringUtils.isNotEmpty(isValid)){
			prdBscInfoVO.setIsValid(Integer.valueOf(isValid));
		}
		prdBscInfoVO.setPrdClsCd(prdClsCd);
		//判断类型PRD_BUS_CD
		String code = prdTypCd.substring(0, ProductConstant.PRD_TYE_LENGHT);
		if(code.equals(ProductConstant.PRD_CAR_CD) 
				|| code.equals(ProductConstant.PRD_BUS_CD)
				|| code.equals(ProductConstant.PRD_TYP_CD_019)
				|| code.equals(ProductConstant.PRD_TYP_CD_020)){
			PrdCarInfoVO prdCarInfoVO = new PrdCarInfoVO();		//乘用车/专车客车
			//prdCarInfoVO.setPrdSeries(prdSeries);
			prdCarInfoVO.setPrdYr(prdYr);
			prdCarInfoVO.setPrdCyCd(prdCyCd);
			prdCarInfoVO.setOutVol(outVol);
			prdCarInfoVO.setGrboxTypCd(grboxTypCd);
			prdCarInfoVO.setGrboxCfg(grboxCfg);
			prdCarInfoVO.setSeatQtyCd(seatQtyCd);
			prdCarInfoVO.setEngMdl(engMdl_car);
			prdCarInfoVO.setEngMdl(engMdl);
			prdCarInfoVO.setDrvTypCd(drvTypCd);
			prdCarInfoVO.setCarStrcCd(carStrcCd);
			prdCarInfoVO.setCarStrcCfg(carStrcCfg);
			prdCarInfoVO.setPowerTypCd(powerTypCd);
			prdCarInfoVO.setCarCl(carCl);
			if(StringUtils.isNotEmpty(guidePcDouble)){
				prdCarInfoVO.setGuidePc(DecimalUtils.convertYuanToFen(Double.valueOf(guidePcDouble)));//元to分
			}
			if(StringUtils.isNotEmpty(carLen)){
				prdCarInfoVO.setCarLen(Double.valueOf(carLen));
			}
			prdCarInfoVO.setMaxSpd(maxSpd);
			prdCarInfoVO.setPrdWayCd(prdWayCd);
			prdCarInfoVO.setCarMdl(carMdl);
			prdCarInfoVO.setOthCfg(othCfg);
			prdCarInfoVO.setEmiStdCd(emiStdCd);
			if(StringUtils.isNotEmpty(isValid)){
				prdCarInfoVO.setIsValid(Integer.valueOf(isValid));
			}
			if(StringUtils.isNotEmpty(batDeg)){
				prdCarInfoVO.setBatDeg(Double.valueOf(batDeg));
			}
			if(StringUtils.isNotEmpty(extMil)){
				prdCarInfoVO.setExtMil(Double.valueOf(extMil));
			}
			if(StringUtils.isNotEmpty(carVol)){
				prdCarInfoVO.setCarVol(Double.valueOf(carVol));
			}
			prdCarInfoVO.setPrdLvlCd(prdLvlCd);
			prdBscInfoVO.setPrdCarInfoVO(prdCarInfoVO);
		}
		
		return prdBscInfoVO;
	}
	
	/**
	 * 获取产品请求参数(新增)
	 * @param request 请求
	 * @return 
	 */
	private PrdBscInfoVO getRequestParamForPrdAdd(HttpServletRequest request)throws BaseException{
		PrdBscInfoVO prdBscInfoVO = this.getRequestParamForPrd(request);
		prdBscInfoVO.setCrtTm(new Date());
		prdBscInfoVO.setCrtUsrId(CurrentThreadContext.getCurrentUserId());
		if(null!=prdBscInfoVO.getPrdCarInfoVO()){
			prdBscInfoVO.getPrdCarInfoVO().setCrtUsrId(CurrentThreadContext.getCurrentUserId());
			prdBscInfoVO.getPrdCarInfoVO().setCrtTm(new Date());
		}
		return prdBscInfoVO;
	}
	
	/**
	 * 获取产品请求参数(修改)
	 * @param request 请求
	 * @return 
	 */
	private PrdBscInfoVO getRequestParamForPrdModify(HttpServletRequest request)throws BaseException{
		PrdBscInfoVO prdBscInfoVO = this.getRequestParamForPrd(request);
		prdBscInfoVO.setMdfTm(new Date());
		prdBscInfoVO.setMdfUsrId(CurrentThreadContext.getCurrentUserId());
		if(null!=prdBscInfoVO.getPrdCarInfoVO()){
			prdBscInfoVO.getPrdCarInfoVO().setMdfTm(new Date());
			prdBscInfoVO.getPrdCarInfoVO().setMdfUsrId(CurrentThreadContext.getCurrentUserId());
		}
		return prdBscInfoVO;
	}
	
	/**
	 * 导出产品
	 * @return 服务器路径
	 */
	@RequestMapping(value = "/exportProduct.do", method = { RequestMethod.GET})
	@ResponseBody
	public Object exportProduct(HttpServletRequest request, HttpServletResponse response) {
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES,SysLogConstant.LOG_CMM_OPERATE_SUCC);
		String brCd = request.getParameter("brCd");
		String prdMdl = request.getParameter("prdMdl");
		String mfrNm = request.getParameter("mfrNm");
		String audStsCd = request.getParameter("audStsCd");
		String prdTypCd = request.getParameter("prdTypCd");
		String drvTyp = request.getParameter("drvTyp");
		String hp = request.getParameter("hp");
		String isHaveNeedCheckChildPrd = request.getParameter("isHaveNeedCheckChildPrd");

		PrdBscInfoQueryCondition qc = new PrdBscInfoQueryCondition();
		if (StringUtils.isNotBlank(brCd)) {
			qc.setBrCd(brCd);
		}
		if (StringUtils.isNotBlank(prdMdl)) {
			qc.setPrdMdl(prdMdl);
		}
		if (StringUtils.isNotBlank(mfrNm)) {
			qc.setMfrNm(mfrNm);
		}
		if (StringUtils.isNotBlank(audStsCd)) {
			qc.setAudStsCd(audStsCd);
		}
		if (StringUtils.isNotBlank(prdTypCd)) {
			qc.setPrdTypCd(prdTypCd);
		}
		if (StringUtils.isNotBlank(drvTyp)) {
			qc.setDrvTyp(drvTyp);
		}
		if (StringUtils.isNotBlank(hp)) {
			qc.setHp(Long.valueOf(hp));
		}
		if(StringUtils.isNotEmpty(isHaveNeedCheckChildPrd)){
			qc.setIsHaveNeedCheckChildPrd(Integer.valueOf(isHaveNeedCheckChildPrd));
		}
		
		try {
			String exportProductPath = this.prdBscInfoService.exportProduct(qc);
			BaseLogUtils.info(logger, "exportProduct", "===导出产品===Condition:"+JSON.toJSONString(qc)+",Result:"+exportProductPath);
			result.setSuccess(BaseConstant.IS_YESNO_YES);
			result.setInfo(SysLogConstant.LOG_CMM_OPERATE_SUCC);
			result.setData(exportProductPath);
			BaseLogUtils.info(logger, "exportProduct", "===导出产品===,DATA:" + JSONObject.toJSONString(qc)+",Result:"+exportProductPath, CurrentThreadContext.getCurrentUserName());
		} catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.info(logger, "exportProduct", "===导出产品===,DATA:" + JSONObject.toJSONString(qc) + ", ERROR:"+ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
			BaseLogUtils.error(logger, "exportProduct", "===导出产品===,DATA:" + JSONObject.toJSONString(qc) + ", ERROR:"+ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}
		
		return result;
	}
}

